package com.qf.dao.impl;

import com.qf.dao.TypeDao;
import com.qf.entity.Type;
import com.qf.utils.DBUtil;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

/**
 * @Author:YuhuaZhang
 * @Description
 * @Date:Created in 21:18 2021/11/4
 * @Modified By:
 */
public class TypeDaoImpl implements TypeDao {
    @Override
    public List<Type> selectAll() throws SQLException {

        QueryRunner queryRunner=new QueryRunner();

        String sql="select t_id as tid,t_name as tname,t_info as tinfo from type limit 5;";

        List<Type> list=queryRunner.query(DBUtil.getConnection(),sql,new BeanListHandler<Type>(Type.class));
        return list;
    }
}
